// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlForecastRequestParameters : RequestParameters<MlForecastRequestParameters>
	{
	}

	public sealed partial class MlForecastRequest : PlainRequestBase<MlForecastRequestParameters>
	{
		public MlForecastRequest(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningForecast;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("duration")]
		public Elastic.Clients.Elasticsearch.Duration? Duration { get; set; }

		[JsonInclude]
		[JsonPropertyName("expires_in")]
		public Elastic.Clients.Elasticsearch.Duration? ExpiresIn { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_model_memory")]
		public string? MaxModelMemory { get; set; }
	}

	public sealed partial class MlForecastRequestDescriptor : RequestDescriptorBase<MlForecastRequestDescriptor, MlForecastRequestParameters>
	{
		internal MlForecastRequestDescriptor(Action<MlForecastRequestDescriptor> configure) => configure.Invoke(this);
		public MlForecastRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlForecastRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningForecast;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlForecastRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Duration? DurationValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? ExpiresInValue { get; set; }

		private string? MaxModelMemoryValue { get; set; }

		public MlForecastRequestDescriptor Duration(Elastic.Clients.Elasticsearch.Duration? duration)
		{
			DurationValue = duration;
			return Self;
		}

		public MlForecastRequestDescriptor ExpiresIn(Elastic.Clients.Elasticsearch.Duration? expiresIn)
		{
			ExpiresInValue = expiresIn;
			return Self;
		}

		public MlForecastRequestDescriptor MaxModelMemory(string? maxModelMemory)
		{
			MaxModelMemoryValue = maxModelMemory;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (DurationValue is not null)
			{
				writer.WritePropertyName("duration");
				JsonSerializer.Serialize(writer, DurationValue, options);
			}

			if (ExpiresInValue is not null)
			{
				writer.WritePropertyName("expires_in");
				JsonSerializer.Serialize(writer, ExpiresInValue, options);
			}

			if (!string.IsNullOrEmpty(MaxModelMemoryValue))
			{
				writer.WritePropertyName("max_model_memory");
				writer.WriteStringValue(MaxModelMemoryValue);
			}

			writer.WriteEndObject();
		}
	}
}